package com.jsbj.user.controller;

import com.alibaba.fastjson.JSONObject;
import com.jsbj.base.ResultBean;
import com.jsbj.framework.controller.BaseController;
import com.jsbj.user.service.ISysRoleTenantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sysRoleTenantAndMenu")
@ApiIgnore
@Api(value = "角色配置-租户和菜单权限", tags = "角色配置-租户和菜单权限")
public class SysRoleTenantAndMenuController  extends BaseController {

    @Autowired
    private ISysRoleTenantService sysRoleTenantService;

    @ApiOperation("根据角色查询租户和菜单信息")
    @GetMapping("/getTenantAndMenuByRoleId")
    public ResultBean<List<Map<String, Object>>> getTenantAndMenuByRoleId(@RequestParam String roleId) {
        return new ResultBean<List<Map<String, Object>>>(sysRoleTenantService.getTenantAndMenuByRoleId(roleId));
    }

    @ApiOperation("新增或编辑提交")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true)}
    )
    @PostMapping("saveOrUpdate")
    public ResultBean<JSONObject> saveOrUpdate(@RequestBody String inParam) {
        return sysRoleTenantService.saveOrUpdateData(inParam);
    }

    @ApiOperation("删除")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true)}
    )
    @PostMapping("deleteData")
    public ResultBean<JSONObject> deleteData(@RequestBody String inParam) {
        return sysRoleTenantService.deleteData(inParam);
    }

    @ApiOperation("编辑查看详情")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "userId", value = "用户登录id", required = true)}
    )
    @PostMapping("/getDetail")
    public ResultBean<List<String>> getDetail(@RequestBody String inParam) {
        return new ResultBean<List<String>>(sysRoleTenantService.getDetail(inParam));
    }
}
